<template>
	<view class="body">
		<view class="topBack">
			<view class="topUserinfo">
				<image class="avatar" :src="userInfo.avatar" mode=""></image>
				<view class="name">
					<p>{{userInfo.nickname}}</p>
					<view class="vip">
						<view style="margin-left: 10rpx;" class="vip-txt">次卡套餐</view>
					</view>
				</view>
				<!-- <view class="right" @click="goMenuPage('/pages/users/my_card_log/index')">
					次卡记录
					<text class="iconfont icon-xiangyou"></text>
				</view> -->
			</view>
			<!-- 传递 cardList 到子组件 -->
			<movable-swiper v-if="cardList.length>0" :lastDataList="cardList" :height="'360rpx'"
				@click="chooseItem"></movable-swiper>
		</view>
	</view>
</template>

<script>
	import {
		getUserInfo,
		getUserGoodsList
	} from '@/api/user.js';

	export default {
		data() {
			return {
				userInfo: {},
				cardList: []
			};
		},
		mounted() {
			this.getUser();
			this.getList();
		},
		methods: {
			getUser() {
				getUserInfo().then(res => {
					this.userInfo = res.data;
				});
			},
			getList() {
				getUserGoodsList({
					pageSize: "1",
					pageNum: '20'
				}).then(res => {
					this.cardList = res.rows;
					console.log(this.cardList, "")
				});
			},
			chooseItem(item) {
				console.log('点击的卡片:', item);
			},
			goMenuPage(url) {
				uni.navigateTo({
					url
				});
			}
		}
	};
</script>
<style lang="scss" scoped>
	.body {}

	.topBack {
		background: linear-gradient(180deg, #E0A466 0%, #F3F3F3 100%);
	}

	.topUserinfo {
		display: flex;
		justify-content: flex-start;
		height: 200rpx;

		.avatar {
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
			margin: 40rpx 40rpx;
		}

		.name {
			color: #000;
			font-size: 31rpx;
			padding-top: 50rpx;
			font-weight: 600;

			.vip {
				display: flex;
				align-items: center;
				padding: 6rpx 20rpx;
				background: #E0A466;
				border-radius: 18px;
				font-size: 20rpx;
				margin-top: 10rpx;
				color: #fff;

				image {
					width: 27rpx;
					height: 27rpx;
				}
			}
		}

		.right {
			font-weight: 400;
			font-size: 20rpx;
			color: #000;
			line-height: 28rpx;
			text-align: left;
			position: absolute;
			top: 60rpx;
			/* 调整底部距离 */
			right: 40rpx;
			/* 调整右边距离 */

			.icon-xiangyou {
				margin-left: 5rpx;
				font-size: 24rpx;
			}
		}
	}
</style>